'use strict';

const Controller = require('egg').Controller;

class CategoryController extends Controller {
  async index() {
    const { ctx } = this
    let res = await ctx.model.Category.findAll()
    ctx.apiSuccess(res)
  }
  async create() {
    const res=await this.ctx.model.Category.bulkCreate([
      {
        title: "动画",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/1.png",
        desc: "动画",
      },
      {
        title: "番剧",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/2.png",
        desc: "番剧",
      },
      {
        title: "音乐",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/3.png",
        desc: "音乐",
      },
      {
        title: "国创",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/4.png",
        desc: "国创",
      },
      {
        title: "舞蹈",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/5.png",
        desc: "舞蹈",
      },
      {
        title: "游戏",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/6.png",
        desc: "游戏",
      },
      {
        title: "科技",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/7.png",
        desc: "科技",
      },
      {
        title: "数码",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/8.png",
        desc: "数码",
      },
      {
        title: "生活",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/9.png",
        desc: "生活",
      },
      {
        title: "鬼畜",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/10.png",
        desc: "鬼畜",
      },
      {
        title: "时尚",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/11.png",
        desc: "时尚",
      },
      {
        title: "广告",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/12.png",
        desc: "广告",
      },
      {
        title: "娱乐",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/13.png",
        desc: "娱乐",
      },
      {
        title: "影视",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/14.png",
        desc: "影视",
      },
      {
        title: "放映厅",
        cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/15.png",
        desc: "放映厅",
      }
    ])
   /*  let res =await this.ctx.model.Category.create({
      title: "动漫",
      cover: "https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/public/15.png",
    }) */
    console.log(res);
    if (res) {
      this.ctx.apiSuccess(res)
    }
  }
}

module.exports = CategoryController;
